﻿#ifndef FREINDWIDGET_H
#define FREINDWIDGET_H

#include <QWidget>
#include <QMouseEvent>
#include <QGraphicsDropShadowEffect>
#include "json.h"
#include <unordered_map>
#include <QPushButton>
#include <QLabel>
#include <QVBoxLayout>
#include <QVector>
#include "mylistwidgetitem.h"

namespace Ui {
class FreindWidget;
}

class FreindWidget : public QWidget
{
    Q_OBJECT

public:
    explicit FreindWidget(QWidget *parent = nullptr);
    ~FreindWidget();
    void showSearchResult(Json::Value& root);
protected:
    bool eventFilter(QObject *obj, QEvent *event);//解决点击下拉列表窗口移动问题
    void mousePressEvent(QMouseEvent *event);//鼠标点击
    void mouseMoveEvent(QMouseEvent *event);//鼠标移动
    void mouseReleaseEvent(QMouseEvent *event);//鼠标释放
private:
    void setShadow();
    void setIcon(int type);//有新好友请求 则设置为红色图标  否则黑色
private slots:
    void on_btn_close_clicked();

    void on_btn_min_clicked();

    void on_comboBox_sex_currentIndexChanged(const QString &arg1);

    void on_comboBox_age_currentIndexChanged(const QString &arg1);

    void on_btn_find_clicked();

    void on_btn_RList_clicked();

private:
    Ui::FreindWidget *ui;
    bool isPressedWidget;//isPressedWidget和last用来控制窗口移动
    QPoint last;
    std::unordered_map<QString,UserInfo> m_map;//保存用户信息
    std::unordered_map<QString,GroupInfo> m_map2;//保存群信息
    QVector<MyListWidgetItem*> m_listItemVec;
};

#endif // FREINDWIDGET_H
